
 <!DOCTYPE HTML>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  
    <title>关于Typescript | Here. There.</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=3, minimum-scale=1">
    
    <meta name="author" content="被删">
    
    <meta name="description" content="Typescript这事情，当你管理大点的应用的时候，就会感受到它的好处了。">
    
    
    
    
    <link rel="alternate" href="/atom.xml" title="Here. There." type="application/atom+xml">
    
    
    <link rel="icon" href="/img/favicon.ico">
    
    
    <link rel="apple-touch-icon" href="/img/pacman.jpg">
    <link rel="apple-touch-icon-precomposed" href="/img/pacman.jpg">
    
    <link rel="stylesheet" href="/css/style.css">
    
<script type="text/javascript">
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "//hm.baidu.com/hm.js?3d902de4a19cf2bf179534ffd2dd7b7f";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>

</head>

  <body>
    <header>
      <div>
		
			<div id="imglogo">
				<a href="/"><img src="/img/sun.png" alt="Here. There." title="Here. There."/></a>
			</div>
			
			<div id="textlogo">
				<h1 class="site-name"><a href="/" title="Here. There.">Here. There.</a></h1>
				<h2 class="blog-motto">Love ice cream. Love sunshine. Love life. Love the world. Love myself. Love you.</h2>
			</div>
			<div class="navbar"><a class="navbutton navmobile" href="#" title="菜单">
			</a></div>
			<nav class="animated">
				<ul>
					
						<li><a href="/">首页</a></li>
					
						<li><a href="https://github.com/godbasin/godbasin.github.io">所有文章</a></li>
					
						<li><a href="/archives">归档</a></li>
					
						<li><a href="/categories">分类</a></li>
					
						<li><a href="https://godbasin.github.io/front-end-playground">前端游乐场</a></li>
					
						<li><a href="/about">关于我</a></li>
					
				</ul>
			</nav>			
</div>

    </header>
    <div id="container">
      <div id="main" class="post" itemscope itemprop="blogPost">
	<article itemprop="articleBody"> 
		<header class="article-info clearfix">
  <h1 itemprop="name">
    
      <a href="/2017/09/01/about-typescript/" title="关于Typescript" itemprop="url">关于Typescript</a>
  </h1>
  <p class="article-author">By
    
      <a href="https://godbasin.github.io" title="被删">被删</a>
    </p>
  <p class="article-time">
    <time datetime="2017-09-01T13:21:26.000Z" itemprop="datePublished">2017-09-01</time>
    更新日期:<time datetime="2017-09-01T13:21:40.540Z" itemprop="dateModified">2017-09-01</time>
    
  </p>
</header>
	<div class="article-content">
		
		
		<div id="toc" class="toc-article">
			<strong class="toc-title">文章目录</strong>
		<ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#认识Typescript"><span class="toc-number">1.</span> <span class="toc-text">认识Typescript</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#什么是Typescript"><span class="toc-number">1.1.</span> <span class="toc-text">什么是Typescript</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Typescript特性"><span class="toc-number">1.2.</span> <span class="toc-text">Typescript特性</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#TS与JS"><span class="toc-number">1.3.</span> <span class="toc-text">TS与JS</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#参考"><span class="toc-number">1.4.</span> <span class="toc-text">参考</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#使用Typescript"><span class="toc-number">2.</span> <span class="toc-text">使用Typescript</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#基础类型"><span class="toc-number">2.1.</span> <span class="toc-text">基础类型</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#接口"><span class="toc-number">2.2.</span> <span class="toc-text">接口</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#类"><span class="toc-number">2.3.</span> <span class="toc-text">类</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#声明文件"><span class="toc-number">2.4.</span> <span class="toc-text">声明文件</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#项目配置"><span class="toc-number">2.5.</span> <span class="toc-text">项目配置</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#项目迁移"><span class="toc-number">2.6.</span> <span class="toc-text">项目迁移</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#为什么是Typescript"><span class="toc-number">3.</span> <span class="toc-text">为什么是Typescript</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#大型项目常见问题"><span class="toc-number">3.1.</span> <span class="toc-text">大型项目常见问题</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#谁在使用Typescript"><span class="toc-number">3.2.</span> <span class="toc-text">谁在使用Typescript</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Angular说"><span class="toc-number">3.3.</span> <span class="toc-text">Angular说</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Reddit说"><span class="toc-number">3.4.</span> <span class="toc-text">Reddit说</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#为什么使用Typescript"><span class="toc-number">3.5.</span> <span class="toc-text">为什么使用Typescript</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#参考-1"><span class="toc-number">3.6.</span> <span class="toc-text">参考</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#结束语"><span class="toc-number">4.</span> <span class="toc-text">结束语</span></a></li></ol>
		</div>
		
		<p>Typescript这事情，当你管理大点的应用的时候，就会感受到它的好处了。<br><a id="more"></a></p>
<h2 id="认识Typescript"><a href="#认识Typescript" class="headerlink" title="认识Typescript"></a>认识Typescript</h2><hr>
<h3 id="什么是Typescript"><a href="#什么是Typescript" class="headerlink" title="什么是Typescript"></a>什么是Typescript</h3><p>TypeScript是JavaScript的超集，带来了诸多新特性：</p>
<ul>
<li>可选的静态类型</li>
<li>类型接口</li>
<li>在ES6和ES7被主流浏览器支持之前使用它们的新特性</li>
<li>编译为可被所有浏览器支持的JavaScript版本</li>
<li>强大的智能感知</li>
</ul>
<h3 id="Typescript特性"><a href="#Typescript特性" class="headerlink" title="Typescript特性"></a>Typescript特性</h3><ul>
<li>可选静态类型</li>
</ul>
<p>类型可被添加到变量，函数，属性等。这将帮助编译器在App运行之前就能显示出任何潜在的代码警告。</p>
<p>给JavaScript加上可选的类型系统，很多事情是只有静态类型才能做的，给JavaScript加上静态类型后，就能将调试从运行期提前到编码期，诸如类型检查、越界检查这样的功能才能真正发挥作用。TypeScript的开发体验远远超过以往纯JavaScript的开发体验，无需运行程序即可修复潜在bug。</p>
<ul>
<li>支持使用ES6和ES7的新特性</li>
</ul>
<p>在TypeScript中，你可以直接使用ES6的最新特性，在编译时它会自动编译到ES3或ES5。</p>
<ul>
<li>代码自动完成，代码智能感知</li>
</ul>
<h3 id="TS与JS"><a href="#TS与JS" class="headerlink" title="TS与JS"></a>TS与JS</h3><p>TS是一个应用程序级的JavaScript开发语言。<br>TS是JavaScript的超集，可以编译成纯JavaScript。<br>TS跨浏览器、跨操作系统、跨主机，开源。<br>TS始于JS，终于JS。遵循JavaScript的语法和语义，方便了无数的JavaScript开发者。<br>TS可以重用现有的JavaScript代码，调用流行的JavaScript库。<br>TS可以编译成简洁、简单的JavaScript代码，在任意浏览器、Node.js或任何兼容ES3的环境上运行。<br>TypeScript比JavaScript更具开发效率，包括：静态类型检查、基于符号的导航、语句自动完成、代码重构等。<br>TS提供了类、模块和接口，更易于构建组件。</p>
<h3 id="参考"><a href="#参考" class="headerlink" title="参考"></a>参考</h3><ul>
<li><a href="http://www.cnblogs.com/farb/p/4983188.html" target="_blank" rel="external">《TypeScript的全部资料，以后都放这儿了》</a></li>
</ul>
<h2 id="使用Typescript"><a href="#使用Typescript" class="headerlink" title="使用Typescript"></a>使用Typescript</h2><hr>
<p>关于Typescript的语法，更多的可参考<a href="https://tslang.cn/docs/handbook/basic-types.html" target="_blank" rel="external">官方文档</a>，这里只列出常用的：基础类型、接口和类。</p>
<h3 id="基础类型"><a href="#基础类型" class="headerlink" title="基础类型"></a>基础类型</h3><p>TypeScript支持与JavaScript几乎相同的数据类型，此外还提供了实用的枚举类型使用。</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div></pre></td><td class="code"><pre><div class="line"><span class="comment">// 布尔值</span></div><div class="line"><span class="keyword">let</span> isDone: boolean = <span class="literal">false</span>;</div><div class="line"></div><div class="line"><span class="comment">// 数字</span></div><div class="line"><span class="keyword">let</span> decLiteral: number = <span class="number">6</span>;</div><div class="line"></div><div class="line"><span class="comment">// 字符串</span></div><div class="line"><span class="keyword">let</span> name: string = <span class="string">"bob"</span>;</div><div class="line"></div><div class="line"><span class="comment">// 数组常用</span></div><div class="line"><span class="comment">// 在元素类型后面接上 []</span></div><div class="line"><span class="keyword">let</span> list: number[] = [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>];</div><div class="line"></div><div class="line"><span class="comment">// 数组泛型，Array&lt;元素类型&gt;</span></div><div class="line"><span class="keyword">let</span> list: <span class="built_in">Array</span>&lt;number&gt; = [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>];</div><div class="line"></div><div class="line"><span class="comment">// any类型常用于对现有代码进行改写</span></div><div class="line"><span class="keyword">let</span> notSure: any = <span class="number">4</span>;</div><div class="line">notSure = <span class="string">"maybe a string instead"</span>;</div><div class="line">notSure = <span class="literal">false</span>;</div><div class="line"></div><div class="line"><span class="comment">// void类型像是与any类型相反，它表示没有任何类型</span></div><div class="line"><span class="comment">// 函数没有返回值</span></div><div class="line"><span class="function"><span class="keyword">function</span> <span class="title">warnUser</span>(<span class="params"></span>): <span class="title">void</span> </span>&#123;</div><div class="line">   alert(<span class="string">"This is my warning message"</span>);</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="comment">// 默认情况下null和undefined是所有类型的子类型</span></div><div class="line"><span class="comment">// 可以把null和undefined赋值给各种类型的变量</span></div><div class="line"><span class="keyword">let</span> u: <span class="literal">undefined</span> = <span class="literal">undefined</span>;</div><div class="line"><span class="keyword">let</span> n: <span class="literal">null</span> = <span class="literal">null</span>;</div></pre></td></tr></table></figure>
<h3 id="接口"><a href="#接口" class="headerlink" title="接口"></a>接口</h3><p>TypeScript的核心原则之一是对值所具有的结构进行类型检查。<br>它有时被称做“鸭式辨型法”或“结构性子类型化”。 </p>
<p>在TypeScript里，接口的作用就是为这些类型命名和为你的代码或第三方代码定义契约。</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line">interface SquareConfig &#123;</div><div class="line">    <span class="attr">color</span>: string;</div><div class="line">    <span class="comment">// 可选属性</span></div><div class="line">    width?: number;  </div><div class="line">    <span class="comment">// 指定属性 </span></div><div class="line">    type: <span class="number">1</span> | <span class="number">2</span> | <span class="number">3</span>;</div><div class="line">    <span class="comment">// 只读属性  </span></div><div class="line">    readonly x: number; </div><div class="line">    <span class="comment">// 函数类型</span></div><div class="line">    getArea(x: number): number; </div><div class="line">&#125;</div></pre></td></tr></table></figure>
<ul>
<li>接口继承</li>
</ul>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line">interface Shape &#123;</div><div class="line">    <span class="attr">color</span>: string;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="comment">// 接口继承</span></div><div class="line"><span class="comment">// 此时Square同时具有两个属性</span></div><div class="line">interface Square extends Shape &#123;</div><div class="line">    <span class="attr">sideLength</span>: number;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h3 id="类"><a href="#类" class="headerlink" title="类"></a>类</h3><p>ECMAScript 6开始，JavaScript程序员将能够使用基于类的面向对象的方式。</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line"><span class="class"><span class="keyword">class</span> <span class="title">Greeter</span> </span>&#123;</div><div class="line">    greeting: string;</div><div class="line">    <span class="keyword">constructor</span>(message: string) &#123;</div><div class="line">        <span class="keyword">this</span>.greeting = message;</div><div class="line">    &#125;</div><div class="line">    greet() &#123;</div><div class="line">        <span class="keyword">return</span> <span class="string">"Hello, "</span> + <span class="keyword">this</span>.greeting;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="keyword">let</span> greeter = <span class="keyword">new</span> Greeter(<span class="string">"world"</span>);</div></pre></td></tr></table></figure>
<p>当接口继承了一个类类型时，它会继承类的成员但不包括其实现。<br>接口同样会继承到类的private和protected成员。</p>
<p>公共，私有与受保护的修饰符：</p>
<ul>
<li><code>public</code>（默认）: 可以自由的访问程序里定义的成员</li>
<li><code>private</code>: 当成员被标记成<code>private</code>时，它就不能在声明它的类的外部访问</li>
<li><code>protected</code>: <code>protected</code>修饰符与<code>private</code>修饰符的行为很相似，但<code>protected</code>成员在派生类中仍然可以访问</li>
<li><code>readonly</code>: 将属性设置为只读的，只读属性必须在声明时或构造函数里被初始化</li>
</ul>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div></pre></td><td class="code"><pre><div class="line"><span class="class"><span class="keyword">class</span> <span class="title">Person</span> </span>&#123;</div><div class="line">    protected name: string;</div><div class="line">    <span class="keyword">constructor</span>(name: string) &#123; <span class="keyword">this</span>.name = name; &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="class"><span class="keyword">class</span> <span class="title">Employee</span> <span class="keyword">extends</span> <span class="title">Person</span> </span>&#123;</div><div class="line">    private department: string;</div><div class="line"></div><div class="line">    <span class="keyword">constructor</span>(name: string, department: string) &#123;</div><div class="line">        <span class="keyword">super</span>(name)</div><div class="line">        <span class="keyword">this</span>.department = department;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    public getElevatorPitch() &#123;</div><div class="line">        <span class="keyword">return</span> <span class="string">`Hello, my name is <span class="subst">$&#123;<span class="keyword">this</span>.name&#125;</span> and I work in <span class="subst">$&#123;<span class="keyword">this</span>.department&#125;</span>.`</span>;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="keyword">let</span> howard = <span class="keyword">new</span> Employee(<span class="string">"Howard"</span>, <span class="string">"Sales"</span>);</div><div class="line"><span class="built_in">console</span>.log(howard.getElevatorPitch());</div><div class="line"><span class="built_in">console</span>.log(howard.name); <span class="comment">// error</span></div></pre></td></tr></table></figure>
<p>在Typescript中，可以使用ES6很多新的特性，其中类Class也是ES6特性之一。包括<code>getter</code>和<code>setter</code>，其实都是ES6而不是Typescript的特性。<br>但<code>public</code>、<code>private</code>、<code>protected</code>等，则是Typescript中增加的。</p>
<h3 id="声明文件"><a href="#声明文件" class="headerlink" title="声明文件"></a>声明文件</h3><p>大多数情况下，类型声明包的名字总是与它们在npm上的包的名字相同，但是有<code>@types/</code>前缀：</p>
<figure class="highlight cmd"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">npm install -D @types/node</div></pre></td></tr></table></figure>
<p>这里我们参考<code>node.d.ts</code>中的<code>require</code>，在我们在typescript中使用<code>require</code>的时候，若无安装<code>@types/node</code>或是自己声明，会报错的：</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line"><span class="comment">// 声明require</span></div><div class="line">declare <span class="keyword">var</span> <span class="built_in">require</span>: NodeRequire;</div><div class="line">interface NodeModule &#123;</div><div class="line">   <span class="attr">exports</span>: any;</div><div class="line">   <span class="built_in">require</span>: NodeRequireFunction;</div><div class="line">   id: string;</div><div class="line">   filename: string;</div><div class="line">   loaded: boolean;</div><div class="line">   parent: NodeModule | <span class="literal">null</span>;</div><div class="line">   children: NodeModule[];</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h3 id="项目配置"><a href="#项目配置" class="headerlink" title="项目配置"></a>项目配置</h3><p><strong><code>tsconfig.json</code></strong>：文件中指定了用来编译这个项目的根文件和编译选项。<br><strong><code>tslint.json</code></strong>：规则定义。</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div></pre></td><td class="code"><pre><div class="line"><span class="comment">// 常见tsconfig.json</span></div><div class="line">&#123;</div><div class="line">  <span class="string">"compilerOptions"</span>: &#123;</div><div class="line">    <span class="string">"baseUrl"</span>: <span class="string">"src"</span>,               <span class="comment">// 根路径，常在使用paths时候结合使用</span></div><div class="line">    <span class="string">"target"</span>: <span class="string">"es6"</span>,                <span class="comment">// 目标js版本，当需要承接jsx的时候可设为"es6"，常设为"es5"</span></div><div class="line">    <span class="string">"jsx"</span>: <span class="string">"preserve"</span>,              <span class="comment">// 保留jsx的处理，常用在使用jsx时</span></div><div class="line">    <span class="string">"module"</span>: <span class="string">"commonjs"</span>,</div><div class="line">    <span class="string">"sourceMap"</span>: <span class="literal">true</span>,</div><div class="line">    <span class="string">"emitDecoratorMetadata"</span>: <span class="literal">true</span>,  <span class="comment">// 使用装饰器</span></div><div class="line">    <span class="string">"experimentalDecorators"</span>: <span class="literal">true</span>, <span class="comment">// 使用元数据</span></div><div class="line">    <span class="string">"lib"</span>: [</div><div class="line">      <span class="string">"dom"</span>,</div><div class="line">      <span class="string">"es7"</span>,</div><div class="line">      <span class="string">"es6"</span></div><div class="line">    ],</div><div class="line">    <span class="string">"paths"</span>: &#123;</div><div class="line">      <span class="string">"utils"</span>: <span class="string">"utils"</span></div><div class="line">    &#125;</div><div class="line">  &#125;,</div><div class="line">  <span class="string">"exclude"</span>: [</div><div class="line">    <span class="string">"node_modules"</span></div><div class="line">  ]</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h3 id="项目迁移"><a href="#项目迁移" class="headerlink" title="项目迁移"></a>项目迁移</h3><p>常用迁移步骤：</p>
<ol>
<li>安装依赖（<code>typescript</code> / <code>ts-loader</code> / <code>tslib</code>等）</li>
<li>文件重命名（<code>.js =&gt; .ts</code> | <code>.jsx =&gt; .tsx</code>）</li>
<li>添加<code>tsconfig.json</code>和<code>tslint.json</code></li>
<li>调整Webpack配置（<code>resolve.extensions</code> / <code>loaders</code>）</li>
<li>添加声明文件（<code>@types/node</code>等）</li>
</ol>
<h2 id="为什么是Typescript"><a href="#为什么是Typescript" class="headerlink" title="为什么是Typescript"></a>为什么是Typescript</h2><hr>
<h3 id="大型项目常见问题"><a href="#大型项目常见问题" class="headerlink" title="大型项目常见问题"></a>大型项目常见问题</h3><ol>
<li>类型不明确，甚至在使用中转换。</li>
</ol>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> type = <span class="number">1</span>;</div><div class="line">type = <span class="string">'abc'</span>;</div></pre></td></tr></table></figure>
<ol>
<li>对象成员属性不明确，使用容易出错。</li>
</ol>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> obj = &#123;<span class="attr">a</span>: <span class="number">123</span>, <span class="attr">b</span>: <span class="number">323</span>&#125;;</div><div class="line"><span class="built_in">console</span>.log(obj.c);</div></pre></td></tr></table></figure>
<ol>
<li>接口返回内容和格式不明确。</li>
</ol>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">ajax(<span class="string">'url'</span>, <span class="function"><span class="keyword">function</span> (<span class="params">json</span>)</span>&#123;</div><div class="line"> json.result ??</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<ol>
<li><p>接手代码注释不多，相关变量命名不规范，变量类型、接口类型等均难以debug。</p>
</li>
<li><p>重构代码、重命名符号需要改动太多相关文件。</p>
</li>
</ol>
<h3 id="谁在使用Typescript"><a href="#谁在使用Typescript" class="headerlink" title="谁在使用Typescript"></a>谁在使用Typescript</h3><p>框架：<code>Angular</code><br>工具：<code>TSLint</code><br>编译器：<code>VSCode</code><br>工具库：<code>RxJS</code>、<code>UI-ROUTER</code><br>UI：<code>ANT Design</code> React UI库<br>APP：<code>Reddit</code></p>
<h3 id="Angular说"><a href="#Angular说" class="headerlink" title="Angular说"></a>Angular说</h3><ol>
<li>TypeScript 拥有很好的工具。</li>
</ol>
<p>它提供了先进的自动补全功能，导航，以及重构。有这样的工具几乎是开发大型项目的必要条件。没了这些工具，修改代码的恐惧将会导致该代码库在一个半只读（semi-read-only）状态， 并且使大规模重构变得极具风险，同时消耗巨大资金。</p>
<ol>
<li>TypeScript 使抽象概念明确。</li>
</ol>
<p>一个好的设计在于定义良好的接口。支持接口的语言使得表达想法变得更加容易。<br>不能清楚地看到界限，开发者开始依赖具体类型而不是抽象接口，导致了紧密耦合。</p>
<ol>
<li>TypeScript 使代码更易阅读和理解。</li>
</ol>
<h3 id="Reddit说"><a href="#Reddit说" class="headerlink" title="Reddit说"></a>Reddit说</h3><ol>
<li>要支持强类型。</li>
<li>要有很好的配套工具。</li>
<li>已经有了成功案例。</li>
<li>我们的工程师可以很快上手。</li>
<li>能同时工作于客户端和服务器。</li>
<li>有优秀的类库。</li>
</ol>
<p><strong>Typescript  vs Flow</strong>：</p>
<p>Typescript是JavaScript的强类型版本。<br>Flow是通过一组可以添加到JavaScript的注解，然后通过工具检查正确性。<br>Flow的类型注解能自动的被Babel移除。<br>与TypeScript相比，Flow在类型检查中做得更好。<br>Typescript是强类型，能使代码有更少的类型相关bug，更容易构建大型应用，还有着丰富的生态系统。</p>
<p>TypeScript的一大加分项就是其生态系统，TypeScript的支持库实在是太棒了。</p>
<p>并且还支持目前流行的编辑器，比如VSCode, Atom和Sublime Text。<br>此外，TypeScript还支持解析JSDoc。</p>
<h3 id="为什么使用Typescript"><a href="#为什么使用Typescript" class="headerlink" title="为什么使用Typescript"></a>为什么使用Typescript</h3><ol>
<li>提供了先进的自动补全功能，导航，以及重构工具。</li>
</ol>
<p>构建丰富的开发工具从第一天起就成为了TypeScript团队的明确目标。<br>这也是为什么他们构建了编程语言服务，使得编辑器可以提供类型检查以及自动补全的功能。那么多的编辑器都对TypeScript有极好的支持，就是因为TypeScript提供了编程语言服务。</p>
<ol>
<li>是JavaScript的超集，从JavaScript迁移方。。</li>
</ol>
<p>从JavaScript迁移到TypeScript不需要经过大改写。可以慢慢的、一次一个模块的迁移。</p>
<p>随便挑选一个模块，修改文件扩展名<code>.js</code>为<code>.ts</code>，然后逐步添加类型注释。当你完成了这个模块，再选择下一个。<br>一旦整个代码库都被类型化，你就可以开始调整编译器设置，使其对代码的检查更加严格。</p>
<ol>
<li>支持接口，抽象设计。</li>
</ol>
<p>在一个静态类型的编程语言中，使用接口来定义子系统之间的界限。</p>
<ol>
<li>类型的支持，使代码更易阅读和理解。</li>
</ol>
<p>我们不需要深入了解代码的实现，也不需要去阅读文档，就可以更更好地理解代码。</p>
<ol>
<li>生态系统完善，支持库完备，已有不少使用TypeScript的成熟项目。</li>
</ol>
<h3 id="参考-1"><a href="#参考-1" class="headerlink" title="参考"></a>参考</h3><ul>
<li><a href="https://coyee.com/article/10635-why-angular-2-switched-to-typescript" target="_blank" rel="external">《为什么 Angular 2 改用 TypeScript 语言实现》</a></li>
<li><a href="https://zhuanlan.zhihu.com/p/27695708" target="_blank" rel="external">《为什么 Reddit 选择了 TypeScript？》</a></li>
<li><a href="http://www.cnblogs.com/brookshi/p/6505599.html" target="_blank" rel="external">《TypeScript 优秀开源项目大合集》</a></li>
</ul>
<h2 id="结束语"><a href="#结束语" class="headerlink" title="结束语"></a>结束语</h2><hr>
<p>很多时候，当我们维护不同重量级的应用，或是在不同的场景中使用应用的时候，面对的架构选择往往是不一样的。<br>就像我们在很小的页面里使用redux会觉得繁琐，在数据类型不多的对象或接口中使用typescript会觉得没啥效果一样，个人还是认为，好的架构在能遇见拓展性的同时，不过度设计，恰到好处才是最棒的。</p>
  
		
		<p style="margin-top:50px;">
			查看Github有更多内容噢：<a href="https://github.com/godbasin">https://github.com/godbasin</a>
			<br>
			更欢迎来<a href="https://godbasin.github.io/front-end-playground">被删的前端游乐场</a>边撸猫边学前端噢
		</p>
	</div>
	<img src="https://github-imglib-1255459943.cos.ap-chengdu.myqcloud.com/2code2.jpg" width="200" height="200" style="display:block;margin: 0 auto;" />
	<p style="text-align: center;margin-top: 10px;margin-bottom: 20px;">码生艰难，写文不易，给我家猪囤点猫粮了喵~</p>
	<div class="author-right">
  		<p>作者：被删</p>
  		<p>出处：<a href="https://godbasin.github.io">https://godbasin.github.io</a></p>
  		<p>本文版权归作者所有，欢迎转载，但未经作者同意必须保留此段声明，且在文章页面明显位置给出原文连接，否则保留追究法律责任的权利。</p>
	</div>
		<footer class="article-footer clearfix">

  <div class="article-tags">
  
  <span></span> <a href="/tags/分享/">分享</a>
  </div>


<div class="article-categories">
  <span></span>
  <a class="article-category-link" href="/categories/js什锦/">js什锦</a>
</div>



<div class="article-share" id="share">

  
<!-- JiaThis Button BEGIN -->
<div class="jiathis_style_24x24">
	<a class="jiathis_button_qzone"></a>
	<a class="jiathis_button_tsina"></a>
	<a class="jiathis_button_tqq"></a>
	<a class="jiathis_button_weixin"></a>
	<a class="jiathis_button_renren"></a>
	<a href="http://www.jiathis.com/share?uid=2134021" class="jiathis jiathis_txt jtico jtico_jiathis" target="_blank"></a>
</div>
<script type="text/javascript">
var jiathis_config = {data_track_clickback:'true'};
</script>
<script type="text/javascript" src="http://v3.jiathis.com/code_mini/jia.js?uid=2134021" charset="utf-8"></script>
<!-- JiaThis Button END -->   


</div>
</footer>   	       
	</article>
	
<nav class="article-nav clearfix">
 
 <div class="prev" >
 <a href="/2017/09/03/cyclejs-notes-3-use-typescript/" title="Cycle.js学习笔记3--切换到Typescript">
  <strong>PREVIOUS:</strong><br/>
  <span>
  Cycle.js学习笔记3--切换到Typescript</span>
</a>
</div>


<div class="next">
<a href="/2017/08/27/cyclejs-notes-2-use-cyclic-router/"  title="Cycle.js学习笔记2--使用cyclic-router来启动路由">
 <strong>NEXT:</strong><br/> 
 <span>Cycle.js学习笔记2--使用cyclic-router来启动路由
</span>
</a>
</div>

</nav>

	<!-- 如果不是首页且没使用 `comments: false` 关闭评论，则尝试加载评论 -->

    <!-- 配置中启用多说时，导入相应代码 -->
    


</div>  
      <div class="openaside"><a class="navbutton" href="#" title="显示侧边栏"></a></div>

  <div id="toc" class="toc-aside">
  <strong class="toc-title">文章目录</strong>
  <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#认识Typescript"><span class="toc-number">1.</span> <span class="toc-text">认识Typescript</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#什么是Typescript"><span class="toc-number">1.1.</span> <span class="toc-text">什么是Typescript</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Typescript特性"><span class="toc-number">1.2.</span> <span class="toc-text">Typescript特性</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#TS与JS"><span class="toc-number">1.3.</span> <span class="toc-text">TS与JS</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#参考"><span class="toc-number">1.4.</span> <span class="toc-text">参考</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#使用Typescript"><span class="toc-number">2.</span> <span class="toc-text">使用Typescript</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#基础类型"><span class="toc-number">2.1.</span> <span class="toc-text">基础类型</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#接口"><span class="toc-number">2.2.</span> <span class="toc-text">接口</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#类"><span class="toc-number">2.3.</span> <span class="toc-text">类</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#声明文件"><span class="toc-number">2.4.</span> <span class="toc-text">声明文件</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#项目配置"><span class="toc-number">2.5.</span> <span class="toc-text">项目配置</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#项目迁移"><span class="toc-number">2.6.</span> <span class="toc-text">项目迁移</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#为什么是Typescript"><span class="toc-number">3.</span> <span class="toc-text">为什么是Typescript</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#大型项目常见问题"><span class="toc-number">3.1.</span> <span class="toc-text">大型项目常见问题</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#谁在使用Typescript"><span class="toc-number">3.2.</span> <span class="toc-text">谁在使用Typescript</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Angular说"><span class="toc-number">3.3.</span> <span class="toc-text">Angular说</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Reddit说"><span class="toc-number">3.4.</span> <span class="toc-text">Reddit说</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#为什么使用Typescript"><span class="toc-number">3.5.</span> <span class="toc-text">为什么使用Typescript</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#参考-1"><span class="toc-number">3.6.</span> <span class="toc-text">参考</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#结束语"><span class="toc-number">4.</span> <span class="toc-text">结束语</span></a></li></ol>
  </div>

<div id="asidepart">
<div class="closeaside"><a class="closebutton" href="#" title="隐藏侧边栏"></a></div>
<aside class="clearfix">

  	
	<div class="archiveslist">
		<p class="asidetitle">最近文章</p>
			<ul class="archive-list">
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/11/15/wxapp-latest-20191115/" title="小程序开发月刊第11期（20191115）">小程序开发月刊第11期（201911...</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/11/10/change-log/" title="前端 CHANGELOG 生成指南">前端 CHANGELOG 生成指南...</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/11/09/wxapp-global-data-behavior/" title="小程序的奇技淫巧 -- globalDataBehavior管理全局状态">小程序的奇技淫巧 -- global...</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/10/15/wxapp-latest-20191015/" title="小程序开发月刊第十期（20191015）">小程序开发月刊第十期（2019101...</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/10/13/about-front-end-3-growth/" title="前端这几年--3.关于成长和焦虑">前端这几年--3.关于成长和焦虑...</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/09/16/wxapp-latest-20190916/" title="小程序开发月刊第九期（20190916）">小程序开发月刊第九期（2019091...</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/08/15/wxapp-latest-20190815/" title="小程序开发月刊第八期（20190815）">小程序开发月刊第八期（2019081...</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/07/27/front-end-playground/" title="被删的前端游乐场建成！">被删的前端游乐场建成！</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/07/21/vue-for-everyone-3/" title="9102全员学Vue--3.把页面拼成个Web应用">9102全员学Vue--3.把页面拼...</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/07/15/wxapp-latest-20190715/" title="小程序开发月刊第七期（20190715）">小程序开发月刊第七期（2019071...</a>
				</li>
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
			</ul>
	</div>


  
  <div class="archiveslist">
    <p class="asidetitle"><a href="/archives">归档</a></p>
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/11/">十一月 2019</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/10/">十月 2019</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/09/">九月 2019</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/08/">八月 2019</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/07/">七月 2019</a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/06/">六月 2019</a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/05/">五月 2019</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/04/">四月 2019</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/03/">三月 2019</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/02/">二月 2019</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/01/">一月 2019</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/12/">十二月 2018</a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/11/">十一月 2018</a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/10/">十月 2018</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/09/">九月 2018</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/08/">八月 2018</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/07/">七月 2018</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/06/">六月 2018</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/05/">五月 2018</a><span class="archive-list-count">5</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/04/">四月 2018</a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/03/">三月 2018</a><span class="archive-list-count">7</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/02/">二月 2018</a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/01/">一月 2018</a><span class="archive-list-count">9</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/12/">十二月 2017</a><span class="archive-list-count">5</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/11/">十一月 2017</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/10/">十月 2017</a><span class="archive-list-count">5</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/09/">九月 2017</a><span class="archive-list-count">6</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/08/">八月 2017</a><span class="archive-list-count">11</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/07/">七月 2017</a><span class="archive-list-count">9</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/06/">六月 2017</a><span class="archive-list-count">10</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/05/">五月 2017</a><span class="archive-list-count">15</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/04/">四月 2017</a><span class="archive-list-count">7</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/03/">三月 2017</a><span class="archive-list-count">10</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/02/">二月 2017</a><span class="archive-list-count">41</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/01/">一月 2017</a><span class="archive-list-count">6</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/12/">十二月 2016</a><span class="archive-list-count">7</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/11/">十一月 2016</a><span class="archive-list-count">9</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/10/">十月 2016</a><span class="archive-list-count">5</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/09/">九月 2016</a><span class="archive-list-count">7</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/08/">八月 2016</a><span class="archive-list-count">9</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/07/">七月 2016</a><span class="archive-list-count">14</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/06/">六月 2016</a><span class="archive-list-count">9</span></li></ul>
  </div>


  
<div class="archiveslist">
	<p class="asidetitle"><a href="/categories">分类</a></p>
		<ul class="archive-list">
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/CSS炒饭/" title="CSS炒饭">CSS炒饭<sup>3</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/D3小馒头/" title="D3小馒头">D3小馒头<sup>8</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/angular2火锅/" title="angular2火锅">angular2火锅<sup>25</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/angular混搭/" title="angular混搭">angular混搭<sup>33</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/box2djs方糖/" title="box2djs方糖">box2djs方糖<sup>34</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/cyclejs哈根达斯/" title="cyclejs哈根达斯">cyclejs哈根达斯<sup>8</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/jQuery杂烩/" title="jQuery杂烩">jQuery杂烩<sup>3</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/js什锦/" title="js什锦">js什锦<sup>26</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/react沙拉/" title="react沙拉">react沙拉<sup>16</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/three-js奶茶/" title="three.js奶茶">three.js奶茶<sup>5</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/vue八宝粥/" title="vue八宝粥">vue八宝粥<sup>29</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/webpack宾治/" title="webpack宾治">webpack宾治<sup>9</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/web乱炖/" title="web乱炖">web乱炖<sup>2</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/前端满汉全席/" title="前端满汉全席">前端满汉全席<sup>8</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/喵/" title="喵">喵<sup>2</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/小程序双皮奶/" title="小程序双皮奶">小程序双皮奶<sup>27</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/工作这杯茶/" title="工作这杯茶">工作这杯茶<sup>5</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/应用巧克力盒/" title="应用巧克力盒">应用巧克力盒<sup>2</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/思想棉花糖/" title="思想棉花糖">思想棉花糖<sup>8</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/柴米油盐工具集/" title="柴米油盐工具集">柴米油盐工具集<sup>1</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/自动化甜筒/" title="自动化甜筒">自动化甜筒<sup>1</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/非前端钙片/" title="非前端钙片">非前端钙片<sup>7</sup></a>
			</li>
		
		</ul>
</div>


  
<div class="archiveslist">
	<p class="asidetitle">标签</p>
		<ul class="archive-list">
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/分享/" title="分享">分享<sup>44</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/原创部件/" title="原创部件">原创部件<sup>1</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/心态/" title="心态">心态<sup>5</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/教程/" title="教程">教程<sup>73</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/晒猫/" title="晒猫">晒猫<sup>2</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/笔记/" title="笔记">笔记<sup>121</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/算法/" title="算法">算法<sup>9</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/自制插件/" title="自制插件">自制插件<sup>2</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/逻辑实现/" title="逻辑实现">逻辑实现<sup>5</sup></a>
			</li>
		
		</ul>
</div>


    <div class="archiveslist">
    <p class="asidetitle"><a href="/archives">about</a></p>
      <ul class="archive-list">
      	<li class="archive-list-item">
      		<a>wangbeishan@163.com</a>
      		<a href="https://github.com/godbasin">github.com/godbasin</a>
      	</li>
      </ul>
  </div>

  <div class="rsspart">
	<a href="/atom.xml" target="_blank" title="rss">RSS 订阅</a>
</div>

</aside>
</div>
    </div>
    <footer><div id="footer" >
	
	<section class="info">
		<p> 即使梦想再小，却很伟大 ^_^ </p>
	</section>
	 
		<p class="copyright">Powered by <a href="http://hexo.io" target="_blank" title="hexo">hexo</a> and Theme by <a href="https://github.com/A-limon/pacman" target="_blank" title="Pacman">Pacman</a> © 2019 
		
		<a href="https://godbasin.github.io" target="_blank" title="被删">被删</a>
		
		</p>
</div>
</footer>
    <script src="/js/jquery-2.1.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){ 
  $('.navbar').click(function(){
    $('header nav').toggleClass('shownav');
  });
  var myWidth = 0;
  function getSize(){
    if( typeof( window.innerWidth ) == 'number' ) {
      myWidth = window.innerWidth;
    } else if( document.documentElement && document.documentElement.clientWidth) {
      myWidth = document.documentElement.clientWidth;
    };
  };
  var m = $('#main'),
      a = $('#asidepart'),
      c = $('.closeaside'),
      o = $('.openaside');
  $(window).resize(function(){
    getSize(); 
    if (myWidth >= 1024) {
      $('header nav').removeClass('shownav');
    }else
    {
      m.removeClass('moveMain');
      a.css('display', 'block').removeClass('fadeOut');
      o.css('display', 'none');
      
      $('#toc.toc-aside').css('display', 'none');
        
    }
  });
  c.click(function(){
    a.addClass('fadeOut').css('display', 'none');
    o.css('display', 'block').addClass('fadeIn');
    m.addClass('moveMain');
  });
  o.click(function(){
    o.css('display', 'none').removeClass('beforeFadeIn');
    a.css('display', 'block').removeClass('fadeOut').addClass('fadeIn');      
    m.removeClass('moveMain');
  });
  $(window).scroll(function(){
    o.css("top",Math.max(80,260-$(this).scrollTop()));
  });
});
</script>

<script type="text/javascript">
$(document).ready(function(){ 
  var ai = $('.article-content>iframe'),
      ae = $('.article-content>embed'),
      t  = $('#toc'),
      h  = $('article h2')
      ah = $('article h2'),
      ta = $('#toc.toc-aside'),
      o  = $('.openaside'),
      c  = $('.closeaside');
  if(ai.length>0){
    ai.wrap('<div class="video-container" />');
  };
  if(ae.length>0){
   ae.wrap('<div class="video-container" />');
  };
  if(ah.length==0){
    t.css('display','none');
  }else{
    c.click(function(){
      ta.css('display', 'block').addClass('fadeIn');
    });
    o.click(function(){
      ta.css('display', 'none');
    });
    $(window).scroll(function(){
      ta.css("top",Math.max(140,320-$(this).scrollTop()));
    });
  };
});
</script>







  </body>
</html>
